package com.ijunfu.listener;

import org.springframework.context.ApplicationListener;
import org.springframework.context.PayloadApplicationEvent;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;

/**
 *
 * @Title  : 
 * @Author : ijunfu <ijunfu@163.com>
 * @Date   : 2023/11/16 10:52
 * @Version: 1.0
 * @Motto  : 世界很大 世界很小
 *
 */
@Configuration
public class GlobalEvenListenerConfiguration {

    @Bean
    public ApplicationListener applicationListener() {
        return (event) -> {

            if(event instanceof PayloadApplicationEvent) {
                PayloadApplicationEvent e = (PayloadApplicationEvent) event;
                System.out.println(e.getPayload());
            }

        };
    }
}
